xc_domain_save: allocate pfn_err before use
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 19 Jan 2010 09:40:30 +0000 (09:40 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 19 Jan 2010 09:40:30 +0000 (09:40 +0000)
Due to recent changes related to xc_map_foreign_bulk, xc_domain_save
segfaults because it tries to use pfn_err without allocating it first.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxc/xc_domain_save.c

index cdaefb7a73fb183b11d24f6b0a995ec644e0820e..c26330dc9b0789a1e67f2880bb009d5459daeceb 100644 (file)
@@ -1273,6 +1273,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
             if ( batch == 0 )
                 goto skip; /* vanishingly unlikely... */
 
+            pfn_err = realloc(pfn_err, sizeof(int) * batch);
             region_base = xc_map_foreign_bulk(
                 xc_handle, dom, PROT_READ, pfn_type, pfn_err, batch);
             if ( region_base == NULL )
@@ -1832,6 +1833,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
 
     free(pfn_type);
     free(pfn_batch);
+    free(pfn_err);
     free(to_send);
     free(to_fix);
     free(to_skip);